/*
 * OccupancyGrid.h
 *
 *  Created on: 23 янв. 2013
 *      Author: alex
 */

#ifndef OCCUPANCYGRID_H_
#define OCCUPANCYGRID_H_



#include <vector>
using namespace std;

#include "Point.h"

class OccupancyGrid
{

public:
	OccupancyGrid();
	virtual ~OccupancyGrid();
	static OccupancyGrid* instance();
	void setMetrics(int N,int M,double CellX,double CellY);

	Tile RealToLogical(const Point& pnt)const;
	Point LogicalToReal(const Tile& tile)const;
	double at(int x,int y);
	void at(int x,int y,bool occupied);

	int N() {return n;}
	int M() {return m;}

	vector<pair<Tile,double> > getNeighbors(int x, int y);

	bool inRange(int start, int end, int val);
private:
	static OccupancyGrid* _instance;
	vector<vector<pair<int,int> > > _grid;
	int n,m;
	double cellY,cellX;


};

#endif /* OCCUPANCYGRID_H_ */
